﻿//
// Created by 86152 on 2021/5/6.
//

#ifndef CTEST_UTILS_H
#define CTEST_UTILS_H

#include <vector>

// 工具类命名空间
namespace Utils{

    class TreeNode{
    public:
        int value;
        TreeNode* left;
        TreeNode* right;
    };

    class ThreadTreeNode : public TreeNode{
    public:
        int ltag;
        int rtag;
    };

    class TreeManager{
    public:


        TreeNode* getTreeRoot(int n = 10,int min = 0, int max = 100);
        TreeNode* getTreeRoot(int* list, int length);
        TreeNode* getThreadTreeRoot(int n = 10,int min = 0, int max = 100);
        TreeNode* getThreadTreeRoot(int* list, int length);
        // 销毁树
        void destory();

        //
        std::vector<TreeNode*> pool;
    private:

        // 填充数组
        void fillTreePool(std::vector<TreeNode*>& pool, int n, int min, int max);
        void fillThreadTreePool(std::vector<TreeNode*>& pool, int n, int min, int max);

        // 随机初始化

        // 通过数组初始化
        void linkNode(std::vector<TreeNode *> &pool);
        TreeNode* root;

    };



//    class TreeUtils{
//    public:
//        // 生成随机树，树的值
//        static TreeManager getRandomTree(int n = 10,int min = 0, int max = 100);
//
//    private:
//        // 填充数组
//
//    };


}


#endif //CTEST_UTILS_H
